package org.webautotest.reservation;



import org.openqa.selenium.By;
import cn.bmyi.webautotest.aimee.BrowserEmulator;
import cn.bmyi.webautotest.aimee.BrowserEmulator.Element;

/**
 * 封装我的体检预约页面操作及页面元素
 * @author gaowen
 *
 */
public class MyReservationsPage
{
	public BrowserEmulator browser;
	public String url;
	public static class PageElement
	{
		public static final String SEARCH_TITLE_XPATH="/html/body/div/header/div/span";//标题栏标题
		public static final String SEARCH_ORDERTITLE_XPATH="/html/body/div/div/li/h3";//订单标题 （体检预约 - 上海杨浦体检中心）
		public static final String SEARCH_CANCELBUTTON_XPATH="/html/body/div/div/li/a";//取消按钮 
		public static final String SEARCH_NODATAIMAGE_XPATH="/html/body/div/div/div/p";//无数据图标样式
		public static final String SEARCH_POPTITLE_XPATH="/html/body/div[3]/div[1]";//弹窗标题 （确定操作）
		public static final String SEARCH_POPTEXTLINE1_XPATH="/html/body/div[3]/div[2]";//弹窗第一行文字 （您确定要取消这条预约单吗？）
		public static final String SEARCH_POPCONFIRMBUTTON_XPATH="/html/body/div[3]/div[3]/a[2]";//弹窗确认按钮
		public static final String SEARCH_POPCANCELBUTTON_XPATH="/html/body/div[3]/div[3]/a[1]";//弹窗取消按钮
		public static final String SEARCH_BACKBUTTON_XPATH="/html/body/div/header/div/a";//返回按钮
		public static final String SEARCH_POP2CONFIRMBUTTON_XPATH="/html/body/div[5]/div[3]";//取消成功弹窗确认按钮
	}
	
	public MyReservationsPage(BrowserEmulator browser)
	{
		this.browser=browser;
	}
	
	/**
	 * 获取标题栏标题
	 * @return 标题
	 */
	public String getTitle()
	{
		return browser.findElement("xpath", PageElement.SEARCH_TITLE_XPATH).getText();
	}
	
	/**
	 * 获取订单标题
	 * @return 订单标题
	 */
	public String getOrdTitle()
	{
		return browser.findElement("xpath", PageElement.SEARCH_ORDERTITLE_XPATH).getText();
	}
	
	/**
	 * 点击取消按钮
	 */
	public void clickCancelButton()
	{
		By locator=By.xpath(PageElement.SEARCH_CANCELBUTTON_XPATH);
		Element married=browser.new Element(locator);
		married.waitUntilDisplay();
		browser.findElement("xpath", PageElement.SEARCH_CANCELBUTTON_XPATH).click();
	}
	
	/**
	 * 获取弹窗标题
	 * @return 弹窗标题
	 */
	public String getPopTitle()
	{
		return browser.findElement("xpath", PageElement.SEARCH_POPTITLE_XPATH).getText();
	}
	
	/**
	 * 获取弹窗提示第一行内容
	 * @return 弹窗提示第一行内容
	 */
	public String getPopText1()
	{
		return browser.findElement("xpath", PageElement.SEARCH_POPTEXTLINE1_XPATH).getText();
	}
	
	
	/**
	 * 点击弹窗取消按钮
	 */
	public void clickPopCancelButton()
	{
		browser.findElement("xpath", PageElement.SEARCH_POPCANCELBUTTON_XPATH).click();
	}
	
	/**
	 * 点击弹窗确认按钮
	 */
	public void clickPopConfirmButton()
	{
		browser.findElement("xpath", PageElement.SEARCH_POPCONFIRMBUTTON_XPATH).click();
	}
	
	/**
	 * 点击订单标题
	 */
	public void clickOrder()
	{
		browser.findElement("xpath", PageElement.SEARCH_ORDERTITLE_XPATH).click();
	}
	
	/**
	 * 暂无数据样式是否显示
	 * @return true：显示；false：不显示
	 */
	public Boolean isNoDataImgDisplay()
	{
		return browser.findElement("xpath", PageElement.SEARCH_NODATAIMAGE_XPATH).isDisplayed();
	}
	
	/**
	 * 点击返回按钮
	 */
	public void clickBackButton()
	{
		browser.findElement("xpath", PageElement.SEARCH_BACKBUTTON_XPATH).click();
	}
	
	/**
	 * 取消预约成功后点击确认按钮
	 */
	public void clickCancelSuccessConfirmButton()
	{
		browser.findElement("xpath", PageElement.SEARCH_POP2CONFIRMBUTTON_XPATH).click();
	}
}
